package stud.aistar.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import stud.aistar.entity.Image;
import stud.aistar.vo.MedicalVo;

import java.util.List;

/**
 * @version 1.0
 * @Auther: git:jybdd - liming
 * @Description - 本类用于:
 * @Date: 2019/10/12 15:15
 */

public interface MedicalVoMapper {

    @Select("select *,year(inowtime) years,lpad(month(inowtime),2,0) months,lpad(day(inowtime),2,0) days from image where user_id = #{userId} and type = 2")
    List<MedicalVo> findByUsersId(Integer id);

    @Select("select *,year(inowtime) years,lpad(month(inowtime),2,0) months,lpad(day(inowtime),2,0) days from image where id = #{id} and type = 2")
    MedicalVo findByMid(Integer id);

    @Insert("insert into image(link,iname,user_id,type,inowtime) values(#{link},#{iname},#{userId},#{type},#{inowtime})")
    void saveMed(Image image);

    @Update("update image set iname=#{iname} where id=#{id}")
    void updateMed(Image image);
}